package com.whj.ems.controller;

import java.util.ArrayList;
import java.util.List;
import org.springframework.http.HttpEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.whj.ems.entity.NavigateTreeEntity;

@Controller
public class NavigateTreeController {

	/**
	 * 树的实体对象(lyd修改)
	 */
	private NavigateTreeEntity tree;
	/**
	 * 树的实体对象集合
	 */
	
	/**
	 * 接收的id用于异步分级加载的标记
	 */
	private void createTreeNode(String id, String text, boolean leaf,String url,List<NavigateTreeEntity> list) {
		if (tree != null) {
			tree = null;
			tree = new NavigateTreeEntity();
		} else {
			tree = new NavigateTreeEntity();
		}
		tree.setId(id);
		tree.setText(text);
		tree.setLeaf(leaf);
		if(!"".equals(url)&&url!=null){
			tree.setUrl(url);
		}
		list.add(tree);
	}
	@RequestMapping(value="/getNavigateTree.do")
	public  HttpEntity<Object>  getNavigateTree(@RequestParam String orgId) {
		List<NavigateTreeEntity> list = null;
		if (list == null) {
			list = new ArrayList<NavigateTreeEntity>();
		}else{
			list.clear();
		}
		if ("-1".equals(orgId)) {
			this.createTreeNode("0", "企业资料", false,"",list);
			this.createTreeNode("1", "用户管理", false,"",list);
			this.createTreeNode("2", "产品管理", false,"",list);
			this.createTreeNode("3", "导航分类", false,"",list);
			this.createTreeNode("4", "新闻公告", false,"",list);
			this.createTreeNode("5", "下载资料", false,"",list);
			this.createTreeNode("6", "常见问题", false,"",list);
			this.createTreeNode("7", "图片链接", false,"",list);
			this.createTreeNode("8", "留言管理", false,"",list);
			this.createTreeNode("9", "订单管理", false,"",list);
			this.createTreeNode("10","企业管理", false,"",list);
			this.createTreeNode("11","招聘管理", false,"",list);
		} else if ("0".equals(orgId)) {
			this.createTreeNode("01", "企业资料", true,"admin.view.title.titleManagerView",list);
		} else if ("1".equals(orgId)) {
			this.createTreeNode("11", "用户管理", true,"admin.view.tabview.tiebaManagerView",list);
		} else if ("2".equals(orgId)) {
			this.createTreeNode("21", "产品分类", true,"admin.view.tabview.invitationManagerView",list);
			this.createTreeNode("22", "产品管理", true,"admin.view.tabview.invitationManagerView",list);
		}else if ("3".equals(orgId)) {
			this.createTreeNode("31", "导航管理", true,"admin.view.tabview.invitationManagerView",list);
		}else if ("4".equals(orgId)) {
			this.createTreeNode("41", "新闻公告", true,"admin.view.tabview.invitationManagerView",list);
		}else if ("5".equals(orgId)) {
			this.createTreeNode("51", "下载资料", true,"admin.view.tabview.invitationManagerView",list);
		}else if ("6".equals(orgId)) {
			this.createTreeNode("61", "常见问题", true,"admin.view.tabview.invitationManagerView",list);
		}else if ("7".equals(orgId)) {
			this.createTreeNode("71", "图片链接", true,"admin.view.tabview.invitationManagerView",list);
		}else if ("8".equals(orgId)) {
			this.createTreeNode("81", "留言管理", true,"admin.view.tabview.invitationManagerView",list);
		}else if ("9".equals(orgId)) {
			this.createTreeNode("91", "订单管理", true,"admin.view.tabview.invitationManagerView",list);
		}else if ("10".equals(orgId)) {
			this.createTreeNode("101", "企业注册", true,"",list);
			this.createTreeNode("102", "企业产品", true,"admin.view.tabview.invitationManagerView",list);
			this.createTreeNode("103", "企业供应商", true,"admin.view.tabview.invitationManagerView",list);
		}else if ("11".equals(orgId)) {
			this.createTreeNode("111", "人才招聘", true,"admin.view.tabview.invitationManagerView",list);
		}
		HttpEntity<Object> httpEntity =new HttpEntity<Object>(list); 
		return httpEntity;
	}
}
